/*
 * @Author: zhuxiaoyi
 * @Date: 2024-01-26 16:09:04
 * @LastEditor: zhuxiaoyi
 * @LastEditTime: 2024-08-19 15:17:44
 * @Description:
 */
import {
  Body,
  Controller,
  Del,
  File,
  Get,
  Inject,
  Param,
  Post,
  Put,
  Query,
} from '@midwayjs/core';
import { GetTaskDto,changeStausDto ,statusListenDto,createTaskDto} from '../dto/TaskDto';
import { TaskService } from '../service/task.service';
@Controller('/task')
export class APIController {
  @Inject()
  taskService: TaskService;

  @Get('/', { summary: '任务列表' })
  async getList(@Query() params: GetTaskDto) {
    return await this.taskService.getTaskList(params);
  }

  @Get('getTaskById/:id', { summary: '任务进度查询' })
  async getTaskById(@Param('id') id: number) {
    return await this.taskService.getTaskById(id);
  }

  @Del('/:id', { summary: '删除任务' })
  async deleteTask(@Param('id') id: number) {
    return await this.taskService.deleteTask(id);
  }

  @Put('/changeStatus/:id', { summary: '状态修改' })
  async changeStatus(@Param('id') id: number,  @Body() params:changeStausDto ) {
    const { status } = params;
    return await this.taskService.changeStatus(id,status);
  }

  @Put('/statusListen', { summary: '状态监听自动处理' })
  async statusListen(  @Body() params:statusListenDto ) {
    const { status } = params;
    return await this.taskService.changeListenStatus(status);
  }

}
